# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=minio-client
pkgver=0.20241029.153459
# 0.20230323.200304 -> 2023-03-23T20-03-04Z
_pkgver="${pkgver:2:4}-${pkgver:6:2}-${pkgver:8:2}T${pkgver:11:2}-${pkgver:13:2}-${pkgver:15:2}Z"
pkgrel=0
pkgdesc="The MinIO Client"
url="https://min.io/"
arch="all"
license="AGPL-3.0-or-later"
makedepends="go"
source="https://github.com/minio/mc/archive/RELEASE.$_pkgver/minio-client-$pkgver.tar.gz"
builddir="$srcdir/mc-RELEASE.$_pkgver"

# secfixes:
#   0.20230111.031416-r0:
#     - CVE-2022-41717

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	local prefix='github.com/minio/mc/cmd'
	local date=${_pkgver%%T*}
	local time=${_pkgver#*T}

	go build -tags kqueue -o bin/mcli -ldflags "
		-X $prefix.Version=${date}T${time//-/:}
		-X $prefix.CopyrightYear=${date%%-*}
		-X $prefix.ReleaseTag=RELEASE.$_pkgver
		-X $prefix.CommitID=0000000000000000000000000000000000000000
		-X $prefix.ShortCommitID=000000000000
		"
}

check() {
	# mc/cmd is disabled, seems to be outdated and fails on all my systems
	# shellcheck disable=2046
	go test -tags kqueue $(go list ./... | grep -v cmd)
}

package() {
	install -Dm755 bin/mcli -t "$pkgdir"/usr/bin/
}

sha512sums="
dc820f512ea4cfead60f063bf39269315f83759b86f035c2993544e135d003247d7d619bfa3e93ce58c5a3e4a97239b3b41d3f12f4f43a8bdb9fb7fe74850061  minio-client-0.20241029.153459.tar.gz
"
